import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class Handler {

	/**
	 * @param args
	 *            - path of the folder containing the training set i.e.
	 *            C:/Workspace_Fall2011/TextClassifier/TrainingSet, path of the
	 *            stopwords files i.e
	 *            C:/Workspace_Fall2011/TextClassifier/Stopwords.txt path of the
	 *            class names file i.e.
	 *            C:/Workspace_Fall2011/TextClassifier/Training/all-classes-strings.lc.txt
	 */

	public static void main(String[] args) {
		String trainingSetPath, stopwordSource, classesIndex, testDocPath;
		ArrayList<String> vocabulary = new ArrayList<String>();
		HashMap<String, ClassDetails> classInfoMap = new HashMap<String, ClassDetails>();
		ArrayList<String> tokensInTestBody = new ArrayList<String>();

		ClassDetails cd = null;

		trainingSetPath = args[0];
		stopwordSource = args[1];
		classesIndex = args[2];

		// train the classifier
		TrainerResult result = Trainer.preprocessTrainingSet(trainingSetPath,
				stopwordSource, classesIndex);

		classInfoMap = result.getClassInfoMap();
		
		Set<Map.Entry<String, ClassDetails>> set = classInfoMap.entrySet();
		for (Map.Entry<String, ClassDetails> me : set) {
			cd = new ClassDetails();
			cd = me.getValue();
			String currentClass = me.getKey();
			System.out.println("CurrentClass in handler--:"+currentClass);
			System.out.println("PriorProb in handler--:"+cd.getPriorProbOfClass());
		}
		
		
		
		vocabulary = result.getVocabulary();

		// test the classifier

		testDocPath = args[3];
		tokensInTestBody = Tester.preprocessTestDoc(testDocPath,
				stopwordSource);
		System.out
				.println("Tokens in test body:" + tokensInTestBody.toString());
		
		Tester.computeScore(classInfoMap, tokensInTestBody);

	}

}
